package messages;

public class AwayMessage extends Message
{
	private String mySender;
	private String myReciever; 
	private String myText;
	private Long mySrvTimeStamp;
	private Long myClintTimeStamp;
	
	public AwayMessage(){
		super("Away");
		this.mySender = "";
		this.setMyReciever("");
		this.myText = "";
		this.mySrvTimeStamp = System.currentTimeMillis();
	}

	public AwayMessage(String sender, String reciever, String text){
		super("Away");
		this.mySender = sender;
		this.setMyReciever(reciever);
		this.myText = text;
		this.mySrvTimeStamp = System.currentTimeMillis();
	}

	public String getMessage(){
		return this.myText;
	}
	
	public void setMessage(String text){
		this.myText = text;
	}
	
	public String getSender(){
		return this.mySender;
	}
	
	public void setSender(String sender){
		this.mySender = sender;
	}
	
	public Long getClientTimeStamp(){
		return this.myClintTimeStamp;
	}
	
	public void setReciever(Long timeStamp){
		this.myClintTimeStamp = timeStamp;
	}

	public Long getServerTimeStamp(){
		return this.mySrvTimeStamp;
	}

	public void setMyReciever(String myReciever) {
		this.myReciever = myReciever;
	}

	public String getMyReciever() {
		return myReciever;
	}
	
	// return an XML-formatted version of the message
	public String toXML()
	{
		String message = "<message>";
        message += "<type>Away</type>";
        message += "<users>";
        message += "<from><username>" + mySender + "</username></from>";
        message += "<to><username>" + myReciever + "</username></to>";
        message += "</users>";
        message += "<timestamp>" + mySrvTimeStamp +  "</timestamp>";
        message += "<text>" + myText + "</text>";
        message += "</message>\n\0";
        
        return message;
	}
	
}
